# -*- coding: utf-8 -*-
import os
import platform
import threading
def ip():
    __ipList = []
    with open('ip.txt', 'r') as ip_list:
        for i in ip_list:
            __ipList.append(i.strip('\n'))
        return __ipList

def ps():
    __pslist = []
    with open('pas.txt', 'rb') as PassWd_list:
        for i in PassWd_list:
            if len(i) == 0:
                i = None
            __pslist.append(str(i, 'UTF-8').strip('\n'))
        return __pslist


UerDic = dict(zip(ip(), ps()))
log = open('log.txt', 'a')
ip_list = UerDic.keys()

def ping(b):
    print('test is %s' % b)
    if platform.system() == 'Linux':
        CmdStr = 'ping -c 1 %s > /dev/null ' % b
        if os.system(CmdStr)  == 0:
            ping('%s is ok' % b)
            log.write('%s is pong' % b)
        else:
            ping('%s is shutdown' % b)
    else:
        CmdStr = 'ping -n 1 %s > nul' % b
        if os.system(CmdStr)  == 0:
            ping('%s is ok' % b)
            log.write('%s is pong' % b)
        else:
            ping('%s is shutdown' % b)

for i in ip_list:
    c = threading.Thread(target=ping,args=(i,))
    c.start()